﻿package component.validate.action;

import component.validate.exception.ValidateException;
import component.validate.service.IValidateService;
import component.validate.service.ValidateServiceFactory;

public class ValidateAction {
	
	/**
	 * 保存时唯一性验证
	 * @param valFieldValues：需要验证的字段值(第一个元素是id值)
	 * @param conditionValues：条件值
	 * @return 返回提示
	 * @throws ValidateException
	 */
	public String doCheckSaveUnique(Object[] valFieldValues,Object[] conditionValues,String id) throws ValidateException{
		IValidateService validateService = ValidateServiceFactory.getValidateService(id);
		return validateService.checkSaveUnique(valFieldValues, conditionValues);
	}
	
	/**
	 * 删除时关联性验证
	 * @param idFieldValues：需要验证的id值
	 * @param conditionValues：条件值
	 * @return 返回提示
	 * @throws ValidateException
	 */
	public String doCheckDeleteAssociation(Object[] idFieldValues,Object[] conditionValues,String id) throws ValidateException{
		IValidateService validateService = ValidateServiceFactory.getValidateService(id);
		return validateService.checkDeleteAssociation(idFieldValues, conditionValues);
	}
	
	public static void main(String[] args) {
		ValidateAction validateAction = new ValidateAction();
	}
}
